package Integrity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Result {
	
	Result (String UserID,String ResultID,String BillingSiteID, StatementData extract){
		userID = UserID;
        billingSiteID = BillingSiteID;
		resultID = ResultID;
		error_code = extract.get_scraped_error_code();
		base_url = extract.get_scraped_base_url();
		type = extract.get_scraped_type();
		date_time = extract.get_scraped_date_with_time();
	}
        
        public Result(String UserID,String BillingSiteID, Date date)
        {
            userID = UserID;
            billingSiteID = BillingSiteID;
            //System.out.println(date);
            date_time = date;
        }
        
        public void setErrorCode(String code)
        {
            error_code = code;
        }
        
	public String get_userID() {
		return userID;
	}
	public String get_billingSiteID() {
		return billingSiteID;
	}
	public String get_resultID() {
		return resultID;
	}
	public String get_error_code() {
		return error_code;
	}
	public String get_base_url(){
		return base_url;
	}
	public String get_type() {
		return type;
	}
	public Date get_date() {
		return date_time;
	}
	@Override public String toString() {
		StringBuilder resultToString = new StringBuilder();
		String NEW_LINE = System.getProperty("line.separator");
		if (error_code.substring(0,3).equals("ERR")){
			resultToString.append("RESULT OBJECT: " + NEW_LINE);
			resultToString.append("resultID: " + resultID + NEW_LINE);
		}
		else {
			resultToString.append("STATEMENT OBJECT: " + NEW_LINE);
			resultToString.append("StatementID: " + resultID + NEW_LINE);
		}
		resultToString.append("UserID: " + userID + NEW_LINE);
		resultToString.append("billingSiteID: " + billingSiteID + NEW_LINE);
		resultToString.append("base url: " + base_url + NEW_LINE);
		resultToString.append("type: " + type + NEW_LINE);
		resultToString.append("Date and Time: " + df.format(date_time) + NEW_LINE);
		resultToString.append("error code: " + error_code + NEW_LINE);
		return resultToString.toString();
	}
	
	private String userID = "";
    private String billingSiteID = "";
	private String resultID ;
	private String error_code ="";	
	private String base_url="";
	private String type="";
	private Date date_time;
	DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
}
